package com.hope.minio.utils;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class ResultBean implements Serializable {
    public static final Logger log = LoggerFactory.getLogger(ResultBean.class);

    private static final long serialVersionUID = 1L;

    private int code;

    private String msg;

    private Object data;

    public ResultBean(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultBean ok() {
        return new ResultBean(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getDesc(), null);
    }

    public static ResultBean ok(String msg) {
        return new ResultBean(ResultEnum.SUCCESS.getCode(), msg, null);
    }

    public static ResultBean ok(Object data) {
        return new ResultBean(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getDesc(), data);
    }

    public static ResultBean ok(ResultEnum codeEnum) {
        return new ResultBean(codeEnum.getCode(), codeEnum.getDesc(), null);
    }

    public static ResultBean ok(ResultEnum codeEnum, Object data) {
        return new ResultBean(codeEnum.getCode(), codeEnum.getDesc(), data);
    }

    public static ResultBean ok(int code, String msg, Object data) {
        return new ResultBean(code, msg, data);
    }

    public static ResultBean ok(int code, String msg) {
        return new ResultBean(code, msg, null);
    }

    public static ResultBean ok(int code, Object data) {
        return new ResultBean(code, ResultEnum.SUCCESS.getDesc(), data);
    }

    public static ResultBean ok(int code) {
        return new ResultBean(code, ResultEnum.SUCCESS.getDesc(), null);
    }

    public static ResultBean error(Object data) {
        log.debug("返回错误：data={}", data);
        return new ResultBean(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getDesc(), data);
    }

    public static ResultBean error(ResultEnum codeEnum) {
        log.debug("返回错误：code={}, msg={}", codeEnum.getCode(), codeEnum.getDesc());
        return new ResultBean(codeEnum.getCode(), codeEnum.getDesc(), null);
    }

    public static ResultBean error(ResultEnum codeEnum, Object data) {
        log.debug("返回错误：code={}, msg={} ,data={} ", codeEnum.getCode(), codeEnum.getDesc(), data);
        return new ResultBean(codeEnum.getCode(), codeEnum.getDesc(), data);
    }

    public static ResultBean error() {
        return new ResultBean(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getDesc(), null);
    }

    public static ResultBean error(int code, String msg) {
        return new ResultBean(code, msg, null);
    }

    public static ResultBean error(int code, String msg, Object data) {
        return new ResultBean(code, msg, data);
    }

    //给前台返回提示信息 给用户展示，例如年级名称不能为空等···
    public static ResultBean tipsInfo(String msg) {
        return new ResultBean(ResultEnum.TIPS_INFO.getCode(), msg, null);
    }


    public int getCode() {
        return code;
    }


    public void setCode(int code) {
        this.code = code;
    }


    public String getMsg() {
        return msg;
    }


    public void setMsg(String msg) {
        this.msg = msg;
    }


    public Object getData() {
        return data;
    }


    public void setData(Object data) {
        this.data = data;
    }


}
